import { build } from 'esbuild'
const path = require('path')
function resolve(dir) {
	return path.join(__dirname, dir)
}
const tsconfig = resolve('tsconfig.json')
const useConfig = {
	entryPoints: [],
	bundle: true,
	platform: 'browser',
	target: 'es2020',
	external: ['rantion-tools/es'],
	format: 'esm',
	tsconfig,
	watch: true
}

// let controller = undefined
export default function() {
	return {
		apply: 'serve',
		name: 'vite-plugin-solve',
		config: async () => {
			await build(useConfig)
			return undefined
		}
	}
}
